package com.hyt.it.ogt.kq.service.gov.model.excel.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.hyt.it.ogt.kq.service.gov.model.excel.TimeRoomCandidateXySheet;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * 兴业银行，编排文件导入
 * @author chengxh
 * @since 2022-01-05
 */

@Slf4j
public class TimeRoomCandidateXyListener extends AbstractAnalysisListener<TimeRoomCandidateXySheet>{

    private  List<TimeRoomCandidateXySheet> list ;

    public TimeRoomCandidateXyListener(){
        this.list =  new ArrayList<TimeRoomCandidateXySheet>();
    }

    @Override
    public void invoke(TimeRoomCandidateXySheet timeRoomCandidateXySheet, AnalysisContext analysisContext) {
        list.add(timeRoomCandidateXySheet);
    }

    /**
     * 所有数据解析完成了 都会来调用
     *
     * @param context
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        // 这里也要保存数据，确保最后遗留的数据也存储到数据库
        log.info("所有数据解析完成！",list.size());
    }

    /**
     * 获取验证后的数据
     * @return
     */
    public List<TimeRoomCandidateXySheet> getTimeRoomCandidateList() {
        return this.list;
    }

}
